Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
@eeue56/ts-core
Advanced tools
Core library for TypeScript inspired by Elm. It contains only some of the more relevant data structures and functions.
Part of the Hiraeth collection.
npm install --save-dev @eeue56/ts-core
npm run build
npm run test
See src
Some useful tools for functional programming - piping, and composing. Both of these can be used to chain functions.
import { Basics } from '@eeue56/ts-core';
// take an argument then pipe it to a variable number of functions
// for example this is 10
const doubleLength = Basics.pipe(
'hello',
(str: string) => {
return str.length;
},
(length: number) => {
return length + length;
}
);
// a function that turns composes each function given as an argument
const func = Basics.compose(
(str: string) => {
return str.length;
},
(length: number) => {
return length + length;
}
);
// this is 10
const anotherDoubleLength = func('hello');
console.log('Expecting 10', anotherDoubleLength);
See src
Not particularly useful in JS as impurity doesn't matter, but sometimes it's nice to log what you're returning.
import { Debug } from '@eeue56/ts-core';
// returns the same object as was logged
function getSomeObject(someObject){
return Debug.log("My name is", someObject);
}
See src
A Maybe/Optional type. Useful for when dealing with a value that can either be a value, or nothing.
import { Maybe } from '@eeue56/ts-core';
const someNothingMaybe = Maybe.Nothing();
const aValueOfZeroFromTheMaybe = Maybe.withDefault(0, someNothingMaybe);
const identity = (x) => x;
const someJustMaybe = Maybe.Just(10);
const newMaybe = Maybe.map(identity, someJustMaybe);
const aValueOfTenFromTheMaybe = Maybe.withDefault(0, someJustMaybe);
See src
A Result type. Useful for when dealing with a value that can either be a value, or an error.
import { Result } from '@eeue56/ts-core';
const someResult = Result.Ok(10);
const double = (x) => x + x;
const newResult = Result.map(double, someResult);
const someResultValue = Result.withDefault(0, newResult);
const someError = Result.Err("Failed to parse on line 10");
const strLength = (x) => x.length;
const newError = Result.mapError(strLength, someError);
const someStringResult = Result.Ok("Hello");
const hello = Result.either(someStringResult);
const failedToParseOnLine10 = Result.either(someError);
See src
A Tuple type of size 2. Useful for combining a pair of values. Generally named objects are more useful than Tuples, however.
import { Tuple } from '@eeue56/ts-core';
const someTuple = Tuple.pair(10, "okay");
const someNewTuple = Tuple.mapFirst(double, someTuple);
const someOtherTuple = Tuple.mapSecond(strLength, someTuple);
const someFirstValue = Tuple.first(someOtherTuple);
const someSecondValue = Tuple.second(someOtherTuple);
FAQs
Core library for TypeScript inspired by Elm
The npm package @eeue56/ts-core receives a total of 21 weekly downloads. As such, @eeue56/ts-core popularity was classified as not popular.
We found that @eeue56/ts-core demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.